import { useState, useRef, useEffect } from "react";

function VideoPlayer({ src, isPlaying }) {
	const ref = useRef(null);

	useEffect(() => {
		if (isPlaying) {
      // console.log('调用 video.play()');
			ref.current.play();
		} else {
      // console.log('调用 video.pause()');
			ref.current.pause();
		}
	}, [isPlaying]);

	return <video ref={ref} src={src} loop playsInline />;
}

export default VideoPlayer;
